package com.ella.config;

import com.google.code.kaptcha.Producer;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

@Configuration
public class KaptchaConfig {

	@Bean
	public Producer producer() {
		Properties properties = new Properties();
        //设置验证码的宽度
		properties.setProperty("kaptcha.image.width", "150");
		//设置验证码的长度
		properties.setProperty("kaptcha.image.height", "50");
		//设置验证码字符串生成的数据
		properties.setProperty("kaptcha.textproducer.char.string","0123456789");
		//设置字符串的长度
		properties.setProperty("kaptcha.textproducer.char.length","4");
		Config config = new Config(properties);
		DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
		defaultKaptcha.setConfig(config);
		return defaultKaptcha;
	}

}
